package com.qst.controller;

import com.qst.pojo.vo.DashboardStatsVO;
import com.qst.service.DashboardService;
import com.qst.util.Result;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 仪表板控制器
 */
@RestController
@RequestMapping("/api/dashboard")
public class DashboardController {

    private static final Logger logger = LoggerFactory.getLogger(DashboardController.class);

    @Autowired
    private DashboardService dashboardService;

    /**
     * 获取仪表板统计数据
     * @return 统计数据
     */
    @GetMapping("/stats")
    public Result<DashboardStatsVO> getDashboardStats() {
        try {
            DashboardStatsVO stats = dashboardService.getDashboardStats();
            return Result.success(stats);
        } catch (Exception e) {
            logger.error("获取仪表板统计数据失败", e);
            return Result.error("获取统计数据失败");
        }
    }
}


